package com.example.demo.service.impl;

import com.example.demo.model.goods;
import com.example.demo.repository.goodsRepository;
import com.example.demo.service.goodsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.transaction.Transactional;
import java.util.List;

@Transactional
@Service
public class goodsServiceImpl implements goodsService {
    @Resource
    private goodsRepository goodRepository;


    @Override
    public goods findById(String id) {
        return goodRepository.findById(id).get();
    }

    @Override
    public List<goods> findAll() {
        return goodRepository.findAll();
    }

    @Override
    public void delete(String id) {
        goodRepository.deleteById(id);
    }

    @Override
    public goods save(goods good) {
        return goodRepository.save(good);
    }
    @Override
    public void deleteAllByGnameIsNull()
    {
        goodRepository.deleteAllByGnameIsNull();
    }

}
